
<template>
<h2>理财添加信息</h2>
    <table border="1" class="table table-bordered"> 
        <tr>
            <td>项目名称:</td>
            <td>
                <input type="text" v-model="data.I_Name">
            </td>
        </tr>
        <tr>
            <td>年收益:</td>
            <td>
                <input type="text" v-model="data.I_YearPrice">
            </td>
        </tr>
        <tr>
            <td>月收益:</td>
            <td>
                <input type="text" v-model="data.I_MonPrice">
            </td>
        </tr>
        <tr>
            <td>最低金额:</td>
            <td>
                <input type="text" v-model="data.I_Price">
            </td>
        </tr>
        <tr>
            <td>理财人数:</td>
            <td>
                <input type="text" v-model="data.I_Number">
            </td>
        </tr>
        <tr>
            <td>风险等级:</td>
            <td>
                <input type="text" v-model="data.I_State">
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
            <input type="button" value="添加" @click="SaveData">
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
    import { ref } from 'vue';
    import { useRouter } from 'vue-router';
    import axios from 'axios'
    const router=useRouter();
    const data=ref({
        I_Id:0,
        I_Name:"",
        I_YearPrice:"",
        I_MonPrice:"",
        I_Price:"",
        I_Number:"",
        I_State:""
    })
    const SaveData=()=>{
        axios({
            method:"post",
            url:"http://localhost:54675/api/Goods/AddData",
            data:{
                I_Name:data.value.I_Name,
                I_YearPrice:data.value.I_YearPrice,
                I_MonPrice:data.value.I_MonPrice,
                I_Price:data.value.I_Price,
                I_Number:data.value.I_Number,
                I_State:data.value.I_State,
            }
        })
        .then(function(res){
            if(res.data>0){
                alert("添加成功");
                router.push("./ShowWorld");
            }
            else{
                alert("添加失败");
                return;
            }
        })
    }


</script>